Skip to content

fix(golang): skip out-of-repo local replace targets to avoid nil panic#188

Merged
Duslia merged 2 commits intocloudwego:mainfrom
wzekin:fix/golang-out-of-repo-local-replace
May 8, 2026
Merged

fix(golang): skip out-of-repo local replace targets to avoid nil panic#188
Duslia merged 2 commits intocloudwego:mainfrom
wzekin:fix/golang-out-of-repo-local-replace

Conversation

@wzekin
Copy link
Copy Markdown
Collaborator

@wzekin wzekin commented May 8, 2026

Local replace => /abs or replace => ../outside targets are not walked by collectGoMods, so they are absent from p.repo.Modules. ParseRepo's old @-based skip didn't filter them, causing a nil deref on mod.Dir.

Switch ParseRepo's skip to the canonical signal (mod == nil) and have getDeps only record local replace deps whose target lives inside the repo root.

What type of PR is this?

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) Translate the PR title into Chinese.

修复当存在 Replace 到外部时,ABCoder panic 的问题

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:
zh(optional):

(Optional) Which issue(s) this PR fixes:

(optional) The PR that updates user documentation:

Local `replace => /abs` or `replace => ../outside` targets are not walked
by collectGoMods, so they are absent from p.repo.Modules. ParseRepo's old
`@`-based skip didn't filter them, causing a nil deref on mod.Dir.

Switch ParseRepo's skip to the canonical signal (mod == nil) and have
getDeps only record local replace deps whose target lives inside the
repo root.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ion entries

Switching the skip purely to mod==nil broke deduplication: getDeps writes
deps[self] = self+'@'+commit for the current module (via getCommitHash),
and that self-entry has mod != nil, so it triggered an extra ParseModule
pass that re-walked the dir and reset Files entries (clearing Imports /
Package on already-parsed files in submodules).

Restore the existing strings.Contains(lib.path, "@") skip and add the
mod == nil guard after it — that catches out-of-repo local-replace
entries (which carry no '@' since they have no version) without breaking
the self-version dedup.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Duslia Duslia merged commit ef0f3e7 into cloudwego:main May 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants